package com.avery.mile.hadoop.rpc.hadoop;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;
import org.apache.log4j.BasicConfigurator;

import java.io.IOException;
import java.net.InetSocketAddress;

/**
 *
 * @author avery
 * @date 2018/12/26
 */
public class HadoopRpcClient {

    public static void main(String[] args) {
        BasicConfigurator.configure();

        InetSocketAddress inetSocketAddress = new InetSocketAddress(
                HadoopRpcServer.IP, HadoopRpcServer.PORT);

        try {
            HadoopRpcProtocol proxy = (HadoopRpcProtocol) RPC.waitForProxy(
                    HadoopRpcProtocol.class, HadoopRpcProtoclImpl.versionID, inetSocketAddress,
                    new Configuration());
            String result = proxy.sayHello("avery");
            System.out.println("re: " + result);
            RPC.stopProxy(proxy);
        } catch (IOException e) {
        }
    }
}
